package com.panopset.swing;


import com.panopset.gui.Widgets;
import com.panopset.net.ftp.Operation;
import com.panopset.net.ftp.Server;

/**
 * FTP Site.
 *
 * @author Karl Dinwiddie
 *
 */
public final class FtpSite {

    /**
     * Number of params is 4.
     */
    private static final int NUM_PARAMS = 4;

    /**
     * Entry point.
     * @param s s[0] = ftp url
     *          s[1] = remote directory
     *          s[2] = user id
     *          s[3] = local directory
     * @throws Exception Exception.
     */
    public static void main(final String... s) throws Exception {
        if (s == null || s.length != NUM_PARAMS) {
            printUsage();
            return;
        }

        String pwd = Widgets.promptForPassword();
        int i = 0;

        Operation op = new Operation(new Server(

        s[i++], s[i++], s[i++], pwd));

        op.setLocalPath(s[i]);

        op.putFile();
    }

    /**
     * Print usage.
     */
    private static void printUsage() {
        System.out.println("java FtpSite <ftp url>"
                + " <remote directory>"
                + " <user id>"
                + " <local directory>");
    }

    /**
     * Prevent instantiation.
     */
    private FtpSite() { }
}
